package one.stand.request.statistics;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

/**
 * Created by renz on 2019/10/24 01:04
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BeginAndEndDateWrapper {
    private String beginDate;

    private String endDate;

    /**
     * 时间统计类型
     * 0:今日;1:昨日;2:7天;3:30天
     */
    public static BeginAndEndDateWrapper build(Integer timeType) {
        String beginDate;
        String endDate;
        LocalDate now = LocalDate.now();

        switch (timeType) {
        case 1:
            beginDate = now.plusDays(-1).toString();
            endDate = now.toString();
            break;
        case 2:
            beginDate = now.plusDays(-7).toString();
            endDate = now.toString();
            break;
        case 3:
            beginDate = now.plusMonths(-1).toString();
            endDate = now.toString();
            break;
        default:
            beginDate = now.toString();
            endDate = now.plusDays(1).toString();
        }
        return new BeginAndEndDateWrapper(beginDate, endDate);
    }
}
